<?php
class Category
{
    public static $chatRoomCategories = array(
        'categories'    =>  array(
            array('id' => '1', 'name' => 'K歌之王', 'intro' => '呼朋唤友，一展歌喉', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/1.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/1.png'),
            array('id' => '7', 'name' => '说出方言', 'intro' => '天南地北来认亲', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/7.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/7.png'),
            array('id' => '5', 'name' => '星座游戏', 'intro' => '妈妈再也不用担心我无聊啦', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/5.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/5.png'),
            array('id' => '3', 'name' => '谈情说爱', 'intro' => '情感八卦，聊以自娱', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/3.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/3.png'),
            array('id' => '4', 'name' => '勾搭聊骚', 'intro' => '专注闲聊勾搭20年', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/4.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/4.png'),
            array('id' => '6', 'name' => '迷妹日常', 'intro' => '抱紧本命，一起舔屏',    'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/6.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/6.png'),
            array('id' => '2', 'name' => '搞笑段子', 'intro' => '白天哈哈哈，晚上嘿嘿嘿', 'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/2.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/2.png'),
            array('id' => '8', 'name' => '二次元君', 'intro' => '既宅又腐，前途未卜',    'cover' => 'http://d.fenfenriji.com/diary/chatroom/category/icon/8.png', 'cover_s' => 'http://d.fenfenriji.com/diary/chatroom/category/icon_s/8.png'),
         ),
        'counts'    =>  7
    );

    public static function getChatRoomCategories(){
        $url = AC::getProtocolUriByOS(AC::$cdn_url_d);
        $chatRoomCategories = array(
            'categories'    =>  array(
                array('id' => '1', 'name' => 'K歌之王', 'intro' => '呼朋唤友，一展歌喉', 'cover' => $url.'/diary/chatroom/category/icon/1.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/1.png'),
                array('id' => '7', 'name' => '说出方言', 'intro' => '天南地北来认亲', 'cover' => $url.'/diary/chatroom/category/icon/7.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/7.png'),
                array('id' => '5', 'name' => '星座游戏', 'intro' => '妈妈再也不用担心我无聊啦', 'cover' => $url.'/diary/chatroom/category/icon/5.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/5.png'),
                array('id' => '3', 'name' => '谈情说爱', 'intro' => '情感八卦，聊以自娱', 'cover' => $url.'/diary/chatroom/category/icon/3.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/3.png'),
                array('id' => '4', 'name' => '勾搭聊骚', 'intro' => '专注闲聊勾搭20年', 'cover' => $url.'/diary/chatroom/category/icon/4.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/4.png'),
                array('id' => '6', 'name' => '迷妹日常', 'intro' => '抱紧本命，一起舔屏',    'cover' => $url.'/diary/chatroom/category/icon/6.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/6.png'),
                array('id' => '2', 'name' => '搞笑段子', 'intro' => '白天哈哈哈，晚上嘿嘿嘿', 'cover' => $url.'/diary/chatroom/category/icon/2.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/2.png'),
                array('id' => '8', 'name' => '二次元君', 'intro' => '既宅又腐，前途未卜',    'cover' => $url.'/diary/chatroom/category/icon/8.png', 'cover_s' => $url.'/diary/chatroom/category/icon_s/8.png'),
            ),
            'counts'    =>  8
        );
        return $chatRoomCategories;
    }
    
    public static function getChatRoomCategoryIds () {
        $categories = self::getChatRoomCategories();
        $categories = $categories['categories'];
        $categoryIds = array();
        foreach ($categories as $value) {
            $categoryIds[] = $value['id'];
        }
        
        return $categoryIds;
    }
    
    public static function checkIsValidCategory ($id) {
        $categoryIds = Category::getChatRoomCategoryIds();
        if (in_array($id, $categoryIds)) {
            return true;
        }
        
        return false;
    }
    
    public static function getCategoryInfoById ($id) {
        if (empty($id)) return array();

        $categories = self::getChatRoomCategories();
        $categories = $categories['categories'];
        $categoryInfo = array();
        foreach ($categories as $value) {
            if ($id == $value['id']) {
                $categoryInfo = $value;
                break;
            }
        }
        
        return $categoryInfo;
    }
}